<template>
	<div class="container">
		<!-- errorCode !=0 显示错误代码 -->
		<error-tip :errorCode="errorCode" v-if="errorCode"></error-tip>
		<div v-else>
			<day-card :dayData = 'dayData'></day-card>
			<day-list :dayData = 'dayData'></day-list>
		</div>
	</div>
</template>

<script>
import  getData from '@/services/index'
import { getNowDate } from '@/libs/utils'
import { onMounted, computed } from 'vue'
import { useStore } from 'vuex'
import DayCard from '@/components/DayPage/Card'
import DayList from '@/components/DayPage/List'
export default {
	setup() {
		const store = useStore()
		onMounted(() => {
			let field = store.state.field
			getData(store, field, getNowDate(field))
		})

		return {
			// 使用computed计算属性，实现响应式
			dayData: computed(() => store.state.dayData),
			errorCode: computed(() => store.state.errorCode)
		}
	},
	components: {
		DayCard,
		DayList
	}
}
</script>

<style lang="less" scoped>

</style>